//
//  TestViewController.m
//  CoollangTennisBall
//
//  Created by Coollang on 2017/8/30.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "TestViewController.h"
#import "NewCurveLineChartView.h"

@interface TestViewController ()
@property (weak, nonatomic) IBOutlet NewCurveLineChartView *curveChartview;
@property (weak, nonatomic) IBOutlet UILabel *textLabel;

@end

@implementation TestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self configerCurveChartView];
}

- (void)configerCurveChartView {
    [self.curveChartview ConfigerTheme:kTennisBaseStyle];

    NSArray *xVauls = @[@0,@18,@36,@54,@72,@90,@108,@126,@144,@162];
    
    NSArray *yValus = @[@70,@68,@81,@85,@61,@72,@69,@66,@70,@81];
    NSArray *yValus2 = @[@76,@71,@66,@67,@74,@71,@82,@71,@69,@77];
    
    [self.curveChartview defaultSuitableSettingCompare:0 maxValue:200 setAxis:kAxisLeft labelCount:5 show:YES drawGridLinesEnabled:YES axisLineColor:nil];
    [self.curveChartview defaultSuitableSettingCompare:0 maxValue:200 setAxis:kAxisRight labelCount:5 show:NO drawGridLinesEnabled:NO axisLineColor:[UIColor clearColor]];
    
    CurveLineItem *lineItem =  [[CurveLineItem alloc] initWithLineWidth:2.0 color:kSelectedColor fullColor:[UIColor colorWithHex:0x20BF9D alpha:0.3] xValues:xVauls yValues:yValus];
    
    CurveLineItem *otherLineItem =  [[CurveLineItem alloc] initWithLineWidth:2.0 color:[UIColor colorWithHex:0xF8C353] fullColor:[UIColor colorWithHex:0xF8C353 alpha:0.3] xValues:xVauls yValues:yValus2];
    [self.curveChartview drawLineWithCurveLineItemArr:@[lineItem,otherLineItem] showAnimation:YES];
    [self.curveChartview configuerXAxisValus:xVauls];
    
    
    NSArray *languageArr = @[@"ce",@"da",@"de",@"el",@"en-GB",@"en",@"es",@"fr",@"it",@"ja",@"pt-PT"];
    
    self.textLabel.text = [self localizedStringForKey:@"iVersionInThisVersionTitle" withDefault:@"版本更新" language:languageArr[arc4random_uniform(12)]];
    
}





- (NSString *)localizedStringForKey:(NSString *)key withDefault:(NSString *)defaultString language:(NSString *)languageStr
{
    NSBundle *versionBundle = nil;
    if (versionBundle == nil)
    {
        NSString *boundPath = [[NSBundle mainBundle] pathForResource:@"iVersion" ofType:@"bundle"];
        versionBundle = [NSBundle bundleWithPath:boundPath];
//        NSString *language = [[NSLocale preferredLanguages] count]? [NSLocale preferredLanguages][0]: @"en";
        NSString *language = languageStr;
        if (![[versionBundle localizations] containsObject:language]) {
              language = [language componentsSeparatedByString:@"-"][0];
        }
        if ([[versionBundle localizations] containsObject:language])
        {
            boundPath = [versionBundle pathForResource:language ofType:@"lproj"];
        }
        versionBundle = [NSBundle bundleWithPath:boundPath] ?: [NSBundle mainBundle];
    }
//    defaultString = [versionBundle localizedStringForKey:key value:defaultString table:nil];
    return [versionBundle localizedStringForKey:key value:defaultString table:nil];
//    return [[NSBundle mainBundle] localizedStringForKey:key value:defaultString table:nil];
}



@end
